Release 10.1A: OpenEdge Data Management:
DataServer for Microsoft SQL Server


RDBMS stored procedure basics

In the OpenEdge environment, you can think of a stored procedure definition as having two basic, interrelated parts:

Table 3–1 identifies and briefly introduces the elements that comprise a stored procedure definition; each of these elements is also more fully discussed later in this chapter.

Table 3–1: Stored procedure language elements
Progress 4GL
Description
RUN STORED–PROCEDURE statement
Executes a stored procedure.
PROC–HANDLE phrase
Allows you to specify a handle to identify a stored procedure.
PROC–STATUS phrase
Reads the return value.
LOAD-RESULT-INTO phrase
Allows data from a result set that is returned for a foreign data source to be put into one or more temp-tables.
PARAM phrase
Identifies run-time parameters to be passed to and/or from the stored procedure.
CLOSE STORED–PROCEDURE statement
Enables the values to be retrieved from the output parameters that you defined for the stored procedure, finalizes result sets data processing, and tells Progress that the stored procedure has ended.

Note: You can substitute the abbreviations RUN STORED–PROC and CLOSE STORED–PROC for the full names RUN STORED–PROCEDURE and CLOSE STORED–PROCEDURE, respectively. The remainder of this guide generally uses the abbreviated form.

See the "Run Stored-Procedure details" section for more details about the reference entries presented in Table 3–1.

As previously noted in Table 3–1, you can pass data types in the RUN STORED-PROCEDURE statement using the PARAM phrase. Table 3–2 lists issues that occur when you pass certain data types as parameters.

Table 3–2: Argument data types for stored procedures 
OpenEdge
MSS data source
DECIMAL
FLOAT
INTEGER
The DataServer defaults all three data types as the OpenEdge INTEGER data type in the schema image. Use the Data Dictionary to update the data type and format information in the field property sheet for the parameter.
CHAR
The data source represents this type as a VARCHAR parameter. Its size cannot exceed the VARCHAR size limit for the associated data source. If the VARCHAR parameter exceeds this limit, it causes an error.
DATE
If you pass a DATE data type as an input parameter and use it in an equality test, the test might fail. In this case, use DATEPART() or DATEDIFF() in the Transact-SQL of your native stored procedure to isolate parts of the date structure for which you might want to test.

Note these stored procedure points:

When you run stored procedures concurrently, the DataServer uses one connection to the data source per procedure. If different stored procedures attempt to update the same record from a single client’s requests, the connections could block each other or a deadlock might occur.

Note: You must define a PROC-HANDLE phrase for each stored procedure phrase that is simultaneously active. This technique provides a CLOSE STORED-PROC statement that can identify the targeted open procedure and close it.

In contrast, since a stored procedure executed with the LOAD-RESULT-INTO phrase implicitly closes the procedure once the execution ends and the data retrieved is placed into temp tables, it essentially runs serially and has no use for a PROC-HANDLE.

The following sections expand on the use of the RUN STORED-PROC statement.


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095